package com.yc.boot.train.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yc.boot.common.model.response.Outcome;
import com.yc.boot.sys.entity.SysUser;
import com.yc.boot.sys.model.find.FindUserPage;
import com.yc.boot.train.business.GradeManageBussiness;
import com.yc.boot.train.entity.TrainCourse;
import com.yc.boot.train.model.find.FindUserByCourse;
import com.yc.boot.train.model.find.GradeManage;
import com.yc.boot.train.model.find.IPageCourse;
import com.yc.boot.train.model.find.IPageGradeManage;
import com.yc.boot.train.model.save.SaveGradeManage;
import com.yc.boot.train.model.update.UpdataGradeManage;
import com.yc.boot.work.entity.TestClass;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * Create with IntelliT IDEA
 *
 * @Author: zhengmingzhe
 * @Date: 2021/12/30/16:24
 * @Description:
 */
@RestController
@Api(tags = "员工分数管理页面接口接口")
@RequestMapping("/grade")
public class GrademanageApi {
    @Resource
    private GradeManageBussiness gradeManageBussiness;

    @GetMapping("/queryGradeManage")
    @ApiOperation("获取分数管理页面信息")
    public Outcome<IPage<GradeManage>> queryGradeManage(IPageGradeManage page){
        return Outcome.success(gradeManageBussiness.queryGradeManage(page));
    }

    @GetMapping("/queryAllCourse")
    @ApiOperation("分页查询所有课程信息")
    public Outcome<IPage<TrainCourse>> queryAllCourse(IPageCourse param){
        return Outcome.success(gradeManageBussiness.queryAllCourse(param));
    }

    @GetMapping("/queryUserPage")
    @ApiOperation("查询没有选择这门课的学生信息")
    public Outcome<List<SysUser>> queryUserPage(FindUserByCourse param){
        return Outcome.success(gradeManageBussiness.queryUserPage(param));
    }

    @PostMapping("/saveGradeManage")
    @ApiOperation("添加分数管理项")
    public Outcome saveGradeManage(@RequestBody @Valid SaveGradeManage param){
        return gradeManageBussiness.saveGradeManage(param);
    }
    @PutMapping("/updateGradeManage")
    @ApiOperation("修改分数管理项")
    public Outcome updateGradeManage(@RequestBody @Valid UpdataGradeManage param){
        return gradeManageBussiness.updateGradeManage(param);
    }
    @DeleteMapping("/delete")
    @ApiOperation("删除")
    public Outcome delete(@RequestBody @Valid @Size(min = 1) List<Long> id) {
        return Outcome.status(gradeManageBussiness.delete(id));
    }
}
